package chapter8.override_.Exercise;

public class OverrideExercise {
    public static void main(String[] args) {
        Person person = new Person("tom",20);
        Student smith = new Student("smith", 25, "123456", 25.00);
        System.out.println(person.say());
        System.out.println(smith.say());

    }
}
class Person {
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String say(){
        return "我的名字是"+name+"\n我的年龄是"+age;
    }
}
class Student extends Person{
    private String id;
    private double score;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    public Student(String name, int age, String id, double score) {
        super(name, age);
        this.id = id;
        this.score = score;
    }
    //重写父类的say方法
    public String say(){
        return super.say()+
                "\n我的id是"+getId()+"\n我的成绩是"+getScore();
    }
}